/*
 * UIControlFactory.h
 *
 *  Created on: 2010-4-6
 *      Author: Administrator
 */

#ifndef UICONTROLFACTORY_H_
#define UICONTROLFACTORY_H_

#include "IUIControl.h"
#include "UIVerticalLayout.h"
#include "UILabel.h"
#include "UIImage.h"

class UIControlFactory
	{
public:
	enum EControlType
		{
		ECT_Unknown,
		ECT_VerticalLayout,
		ECT_HorizontalLayout,
		ECT_Label,
		ECT_Image
		};
public:
	static IUIControl* CreateUIControlL(const TDesC8& aDes)
		{
		EControlType type = ECT_Unknown;
		if(aDes.Compare(KVertivalLayout) == 0)
			type = ECT_VerticalLayout;
		else if(aDes.Compare(KCtrlLabel) == 0)
			type = ECT_Label;
		else if(aDes.Compare(KCtrlImage) == 0)
			type = ECT_Image;
		
		switch(type)
			{
			case ECT_VerticalLayout:
				return new(ELeave) UIVerticalLayout;
				break;
			case ECT_HorizontalLayout:
				return NULL;
				break;
			case ECT_Label:
				return new(ELeave) UILabel;
				break;
			case ECT_Image:
				return new(ELeave) UIImage;
				break;
			default:
				return NULL;
			}
		}
	};

#endif /* UICONTROLFACTORY_H_ */
